package ncu.me.musicplayer.entity;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.JoinEntity;
import org.greenrobot.greendao.annotation.ToOne;
import org.greenrobot.greendao.annotation.Unique;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.DaoException;

/**
 * @Author ye
 * @Date 2020/6/4 15:09
 * @Version 1.0
 */
@Entity
public class CollectInfo {
    @Id(autoincrement = true)
    private Long id;
    @Unique
    private Long musicId;
    private Long time;
    @ToOne(joinProperty = "musicId")
    private MusicInfo musicInfo;
    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;
    /** Used for active entity operations. */
    @Generated(hash = 395631006)
    private transient CollectInfoDao myDao;
    @Generated(hash = 713767376)
    public CollectInfo(Long id, Long musicId, Long time) {
        this.id = id;
        this.musicId = musicId;
        this.time = time;
    }
    @Generated(hash = 781720191)
    public CollectInfo() {
    }
    public Long getId() {
        return this.id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public Long getMusicId() {
        return this.musicId;
    }
    public void setMusicId(Long musicId) {
        this.musicId = musicId;
    }
    public Long getTime() {
        return this.time;
    }
    public void setTime(Long time) {
        this.time = time;
    }
    @Generated(hash = 1132280913)
    private transient Long musicInfo__resolvedKey;
    /** To-one relationship, resolved on first access. */
    @Generated(hash = 354921859)
    public MusicInfo getMusicInfo() {
        Long __key = this.musicId;
        if (musicInfo__resolvedKey == null
                || !musicInfo__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            MusicInfoDao targetDao = daoSession.getMusicInfoDao();
            MusicInfo musicInfoNew = targetDao.load(__key);
            synchronized (this) {
                musicInfo = musicInfoNew;
                musicInfo__resolvedKey = __key;
            }
        }
        return musicInfo;
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 77889278)
    public void setMusicInfo(MusicInfo musicInfo) {
        synchronized (this) {
            this.musicInfo = musicInfo;
            musicId = musicInfo == null ? null : musicInfo.getId();
            musicInfo__resolvedKey = musicId;
        }
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }
    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }
    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 791906233)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getCollectInfoDao() : null;
    }
}
